<?php if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Timeline extends CI_Controller{
	
	var $_public_view;

	function __construct(){
		parent::__construct();	
		$this->load->model('model_user', 'muser');
        $this->load->helper(array('form', 'url','html'));
        $this->load->library('session');
        $this->load->library('pagination');
        $this->config->load('ojexcom');
        $this->_public_view = $this->config->item('public_view');
	}
	
	function index(){
		//cek session
        $isLogin = $this->session->userdata('isLogin');
        $user = ''; $id='';
        if ($isLogin) {
            $user = $this->session->userdata('username');
            $id = $this->session->userdata('user_id');
        }

		
		//header('Content-Type: application/json');
		//echo json_encode($data_output);
		$data = array(
            'output'=> $this->get(),
            'page_title' => 'Cari Perjalanan',
            'page_content' => 'cari_perjalanan',
            'isLogin' => $isLogin, 'user' => $user, 'id' => $id);
        $this->load->view($this->_public_view, $data);
	}

	function get(){
		//cek session
        $isLogin = $this->session->userdata('isLogin');
        $user = ''; $id='';
        if ($isLogin) {
            $user = $this->session->userdata('username');
            $id = $this->session->userdata('user_id');
        }

		if($this->input->post('radius')){
			$myid = $id;
			$radius = $this->input->post('radius');
			$mylat = 0;
			$mylong = 0;
			$query_coor = $this->db->query("SELECT latitude,longitude FROM coordinate WHERE idUser=".$myid);
			$row_coor = $query_coor->row(); 
			if($query_coor ->num_rows() > 0){
				$mylat = $row_coor->latitude;
				$mylong = $row_coor->longitude;
			}
		
			$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC");
			if($query->num_rows() < 1 || $mylat == 0|| $mylong == 0){
				$data_output['timeline'] = "";
			}else{
				$row = $query->row(); 
				$count = 0;
				foreach($query->result() as $row){
					$distance = $this->distance($mylat,$mylong,$row->latitude,$row->longitude);
					if( $distance <= $radius){
						$data_output["timeline"][$count]["id"] = $row->id;
						$data_output["timeline"][$count]["userId"] = $row->userId;
						$data_output["timeline"][$count]["name"] = $row->name;
						$data_output["timeline"][$count]["avatar"] = $row->avatar;
						$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
						$data_output["timeline"][$count]["gender"] = $row->gender;
						$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
						$data_output["timeline"][$count]["status"] = $row->status;
						$data_output["timeline"][$count]["source_label"] = $row->source_label;
						$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
						$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
						$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
						$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
						$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
						$data_output["timeline"][$count]["via"] = $row->via;
						$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
						$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
						$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
						$data_output["timeline"][$count]["notes"] = $row->notes;
						$count++;
					}
				}	
				if($count == 0)				$data_output['timeline'] = "";
			}
		}else{
			$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC LIMIT 20");
			if($query->num_rows() < 1){
				$data_output['timeline'] = "";
			}else{
				$row = $query->row(); 
				$count = 0;
				foreach($query->result() as $row){
					$data_output["timeline"][$count]["id"] = $row->id;
					$data_output["timeline"][$count]["userId"] = $row->userId;
					$data_output["timeline"][$count]["name"] = $row->name;
					$data_output["timeline"][$count]["avatar"] = $row->avatar;
					$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
					$data_output["timeline"][$count]["gender"] = $row->gender;
					$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
					$data_output["timeline"][$count]["status"] = $row->status;
					$data_output["timeline"][$count]["source_label"] = $row->source_label;
					$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
					$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
					$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
					$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
					$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
					$data_output["timeline"][$count]["via"] = $row->via;
					$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
					$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
					$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
					$data_output["timeline"][$count]["notes"] = $row->notes;
					$count++;
				}	
				if($count == 0)				$data_output['timeline'] = "";
			}
		}
		return $data_output;
		// header('Content-Type: application/json');
		// echo json_encode($data_output);
	}
	
	function distance($lat1, $lon1, $lat2, $lon2){
		$radius = 6378100; // radius of earth in meters
		$latDist = $lat1 - $lat2;
		$lngDist = $lon1 - $lon2;
		$latDistRad = deg2rad($latDist);
		$lngDistRad = deg2rad($lngDist);
		$sinLatD = sin($latDistRad);
		$sinLngD = sin($lngDistRad);
		$cosLat1 = cos(deg2rad($lat1));
		$cosLat2 = cos(deg2rad($lat2));
		$a = ($sinLatD/2)*($sinLatD/2) + $cosLat1*$cosLat2*($sinLngD/2)*($sinLngD/2);
		if($a<0) $a = -1*$a;
		$c = 2*atan2(sqrt($a), sqrt(1-$a));
		$distance = ($radius*$c);
		return $distance;
	}
	
	function search(){
		$radius = $this->input->post('amount');
		$sourcelat = $this->input->post('source_latitude');
		$sourcelong = $this->input->post('source_longitude');
		$destinationlat = $this->input->post('destination_latitude');
		$destinationlong = $this->input->post('destination_longitude');
		$source_label = $this->input->post('source_label');
		$destination_label = $this->input->post('destination_label');
		$source_criteria = "";
		if($source_label != NULL && $source_label != '')			$source_criteria = " AND (source_label LIKE '%".$source_label."%' AND departTime >= '".date("Y-m-d H:i:s")."')";
		$destination_criteria = "";
		if($destination_label != NULL && $destination_label != '')			$destination_criteria = " AND (destination_label LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."')";
		$via_criteria = "";
		if($source_label != NULL && $destination_label != NULL && $source_label != '' && $destination_label != '')			$via_criteria = " OR (via LIKE '%".$source_label."%' OR via LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		else if($source_label != NULL && $source_label != '')			$via_criteria = " OR (via LIKE '%".$source_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		else if($destination_label != NULL && $destination_label != '')			$via_criteria = " OR (via LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		$time_criteria = "";
		$from = $this->input->post('from');
		$to = $this->input->post('to');
		if($from != NULL && $to != NULL)			$time_criteria = "AND TIME(departTime) >= '".$from."' AND TIME(departTime)<= '".$to.":00'";
		else if($from != NULL)			$time_criteria = "AND TIME(departTime) >= '".$from."'";
		else if($to != NULL)			$time_criteria = "AND TIME(departTime) <= '".$to.":00'";
		$status_criteria = "";
		$status = $this->input->post('status');
		if ($status!=NULL) {
			if ($status==1) { //Pengemudi
				$status_criteria = " AND t.status='P' ";
			} else if ($status==2) { //Penumpang
				$status_criteria = " AND t.status='U' ";
			}
		}
		$str_query = "SELECT DISTINCT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.`gender`, u.isPremium FROM trip t JOIN `user` u ON u.id=t.userId WHERE t.is_available=1 ".$status_criteria.$time_criteria.$source_criteria.$destination_criteria.$via_criteria." AND departTime >= '".date("Y-m-d H:i:s")."' ORDER BY departTime desc";
		$query = $this->db->query($str_query );
		
		if($query->num_rows() < 1){
			$data_output['timeline'] = "";
		}else{
			$row = $query->row(); 
			$count = 0;
			foreach($query->result() as $row){
				if($sourcelat != NULL && $sourcelong != NULL)					$distance_source = $this->distance($sourcelat,$sourcelong,$row->source_latitude,$row->source_longitude);
				else					$distance_source = NULL;
				if($destinationlat != NULL && $destinationlong != NULL)					$destination_source = $this->distance($destinationlat,$destinationlong,$row->destination_latitude,$row->destination_longitude);
				else					$destination_source = NULL;
				if( ($distance_source == NULL || $distance_source <= 3) && ($destination_source == NULL || $destination_source <= 3)){
					$data_output["timeline"][$count]["id"] = $row->id;
					$data_output["timeline"][$count]["userId"] = $row->userId;
					$data_output["timeline"][$count]["name"] = $row->name;
					$data_output["timeline"][$count]["avatar"] = $row->avatar;
					$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
					$data_output["timeline"][$count]["gender"] = $row->gender;
					$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
					$data_output["timeline"][$count]["status"] = $row->status;
					$data_output["timeline"][$count]["source_label"] = $row->source_label;
					$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
					$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
					$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
					$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
					$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
					$data_output["timeline"][$count]["via"] = $row->via;
					$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
					$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
					$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
					$data_output["timeline"][$count]["notes"] = $row->notes;
					$count++;
				}
			}	
			if($count == 0)				$data_output['timeline'] = "";
		}

		header('Content-Type: application/json');
		echo json_encode($data_output);
	}

	function countTimeline(){
		$radius = $this->input->post('radius');
		$sourcelat = $this->input->post('source_latitude');
		$sourcelong = $this->input->post('source_longitude');
		$destinationlat = $this->input->post('destination_latitude');
		$destinationlong = $this->input->post('destination_longitude');
		$source_label = $this->input->post('source_label');
		$destination_label = $this->input->post('destination_label');
		$source_criteria = "";
		if($source_label != NULL && $source_label != '')			$source_criteria = " AND (source_label LIKE '%".$source_label."%' AND departTime >= '".date("Y-m-d H:i:s")."')";
		$destination_criteria = "";
		if($destination_label != NULL && $destination_label != '')			$destination_criteria = " AND (destination_label LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."')";
		$via_criteria = "";
		if($source_label != NULL && $destination_label != NULL && $source_label != '' && $destination_label != '')			$via_criteria = " OR (via LIKE '%".$source_label."%' OR via LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		else if($source_label != NULL && $source_label != '')			$via_criteria = " OR (via LIKE '%".$source_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		else if($destination_label != NULL && $destination_label != '')			$via_criteria = " OR (via LIKE '%".$destination_label."%' AND departTime >= '".date("Y-m-d H:i:s")."' AND  t.is_available=1 ) ";
		$time_criteria = "";
		$from = $this->input->post('from');
		$to = $this->input->post('to');
		if($from != NULL && $to != NULL)			$time_criteria = "AND TIME(departTime) >= '".$from."' AND TIME(departTime)<= '".$to.":00'";
		else if($from != NULL)			$time_criteria = "AND TIME(departTime) >= '".$from."'";
		else if($to != NULL)			$time_criteria = "AND TIME(departTime) <= '".$to.":00'";
		$status_criteria = "";
		$status = $this->input->post('status');
		if ($status!=NULL) {
			if ($status==1) { //Pengemudi
				$status_criteria = " AND t.status='P' ";
			} else if ($status==2) { //Penumpang
				$status_criteria = " AND t.status='U' ";
			}
		}
		$str_query = "SELECT DISTINCT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.`gender`, u.isPremium FROM trip t JOIN `user` u ON u.id=t.userId WHERE t.is_available=1 ".$status_criteria.$time_criteria.$source_criteria.$destination_criteria.$via_criteria." AND departTime >= '".date("Y-m-d H:i:s")."' ORDER BY departTime desc";
		$query = $this->db->query($str_query );
		
		if($query->num_rows() < 1){
			$data_output['timeline'] = "";
		}else{
			$row = $query->row(); 
			$count = 0;
			foreach($query->result() as $row){
				if($sourcelat != NULL && $sourcelong != NULL)					$distance_source = $this->distance($sourcelat,$sourcelong,$row->source_latitude,$row->source_longitude);
				else					$distance_source = NULL;
				if($destinationlat != NULL && $destinationlong != NULL)					$destination_source = $this->distance($destinationlat,$destinationlong,$row->destination_latitude,$row->destination_longitude);
				else					$destination_source = NULL;
				if( ($distance_source == NULL || $distance_source <= 3) && ($destination_source == NULL || $destination_source <= 3)){
					$data_output["timeline"][$count]["id"] = $row->id;
					$data_output["timeline"][$count]["userId"] = $row->userId;
					$data_output["timeline"][$count]["name"] = $row->name;
					$data_output["timeline"][$count]["avatar"] = $row->avatar;
					$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
					$data_output["timeline"][$count]["gender"] = $row->gender;
					$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
					$data_output["timeline"][$count]["status"] = $row->status;
					$data_output["timeline"][$count]["source_label"] = $row->source_label;
					$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
					$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
					$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
					$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
					$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
					$data_output["timeline"][$count]["via"] = $row->via;
					$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
					$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
					$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
					$data_output["timeline"][$count]["notes"] = $row->notes;
					$count++;
				}
			}	
			if($count == 0)				$data_output['timeline'] = "";
		}
		echo sizeof($data_output['timeline']);
	}

	function cari($page=1){
		//cek session
        $isLogin = $this->session->userdata('isLogin');
        $user = ''; $id='';
        if ($isLogin) {
            $user = $this->session->userdata('username');
            $id = $this->session->userdata('user_id');
        }

        $nitem = 10;
        $count = 0;

		$dari = $this->input->get('dari',true);
		$ke = $this->input->get('ke',true);
		$berangkat = $this->input->get('departTime',true);

		$radius = $this->input->get('radius');
		$pengemudi = $this->input->get('pengemudi');
		$penumpang = $this->input->get('penumpang');
		

		$kriteriaTrip = "";
		if($pengemudi == 'on' and $penumpang==null){
			$kriteriaTrip = "AND t.status = 'P' ";
		} else if($penumpang == 'on' and $pengemudi==null){
			$kriteriaTrip = "AND t.status = 'U' ";
		} else {
			$kriteriaTrip = "";
		}
			
		if($this->input->get('radius')){
			$myid = $id;
			$radius = $this->input->get('radius');
			$mylat = 0;
			$mylong = 0;
			$query_coor = $this->db->query("SELECT latitude,longitude FROM coordinate WHERE idUser=".$myid);
			$row_coor = $query_coor->row(); 
			if($query_coor ->num_rows() > 0){
				$mylat = $row_coor->latitude;
				$mylong = $row_coor->longitude;
			}
			//$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC");
			$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 ".$kriteriaTrip."
									AND source_label LIKE '%".$dari."%'
									AND destination_label LIKE '%".$ke."%'
									AND departTime LIKE '%".$berangkat."%'
									AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC LIMIT 20");
		
			if($query->num_rows() < 1 || $mylat == 0|| $mylong == 0){
				$data_output['timeline'] = "";
			}else{
				$row = $query->row(); 
				$count = 0;
				foreach($query->result() as $row){
					$distance = $this->distance($mylat,$mylong,$row->latitude,$row->longitude);
					if( $distance <= $radius){
						$data_output["timeline"][$count]["id"] = $row->id;
						$data_output["timeline"][$count]["userId"] = $row->userId;
						$data_output["timeline"][$count]["name"] = $row->name;
						$data_output["timeline"][$count]["avatar"] = $row->avatar;
						$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
						$data_output["timeline"][$count]["gender"] = $row->gender;
						$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
						$data_output["timeline"][$count]["status"] = $row->status;
						$data_output["timeline"][$count]["source_label"] = $row->source_label;
						$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
						$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
						$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
						$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
						$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
						$data_output["timeline"][$count]["via"] = $row->via;
						$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
						$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
						$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
						$data_output["timeline"][$count]["notes"] = $row->notes;
						$count++;
					}
				}	
				if($count == 0)				$data_output['timeline'] = "";
			}
		}else{
			//$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC LIMIT 20");
			$query = $this->db->query("SELECT t.*, u.`name`,  u.`avatar`, u.lastUpdatedAvatar, u.isPremium, u.gender, c.latitude, c.longitude FROM trip t JOIN `user` u ON u.id=t.userId JOIN coordinate c ON c.idUser=u.id WHERE  t.is_available=1 ".$kriteriaTrip."
									AND source_label LIKE '%".$dari."%'
									AND destination_label LIKE '%".$ke."%'
									AND departTime LIKE '%".$berangkat."%'
									AND departTime> '".date("Y-m-d H:i:s")."' ORDER BY departTime DESC LIMIT 20");
		
			if($query->num_rows() < 1){
				$data_output['timeline'] = "";
			}else{
				$row = $query->row(); 
				$count = 0;
				foreach($query->result() as $row){
					$data_output["timeline"][$count]["id"] = $row->id;
					$data_output["timeline"][$count]["userId"] = $row->userId;
					$data_output["timeline"][$count]["name"] = $row->name;
					$data_output["timeline"][$count]["avatar"] = $row->avatar;
					$data_output["timeline"][$count]["lastUpdatedAvatar"] = $row->lastUpdatedAvatar;
					$data_output["timeline"][$count]["gender"] = $row->gender;
					$data_output["timeline"][$count]["isPremium"] = $row->isPremium;
					$data_output["timeline"][$count]["status"] = $row->status;
					$data_output["timeline"][$count]["source_label"] = $row->source_label;
					$data_output["timeline"][$count]["source_latitude"] = $row->source_latitude;
					$data_output["timeline"][$count]["source_longitude"] = $row->source_longitude;
					$data_output["timeline"][$count]["destination_label"] = $row->destination_label;
					$data_output["timeline"][$count]["destination_latitude"] = $row->destination_latitude;
					$data_output["timeline"][$count]["destination_longitude"] = $row->destination_longitude;
					$data_output["timeline"][$count]["via"] = $row->via;
					$data_output["timeline"][$count]["priceInRupiah"] = $row->priceInRupiah;
					$data_output["timeline"][$count]["priceInPoint"] = $row->priceInPoint;
					$data_output["timeline"][$count]["departTime"] = date('d-m-Y H:i:s',strtotime($row->departTime));
					$data_output["timeline"][$count]["notes"] = $row->notes;
					$count++;
				}	
				if($count == 0)				$data_output['timeline'] = "";
			}
		}

		if($data_output['timeline']!=""){
			$data_output['timeline'] = array_slice($data_output['timeline'], ($page - 1) * $nitem, $nitem);
		}

		if (count($_GET) > 0)
            $config['suffix'] = '?' . http_build_query($_GET, '', "&");
        $config['base_url'] = site_url('timeline/cari/');
        $config['first_url'] = $config['base_url'] . '?' . http_build_query($_GET);
        $config['total_rows'] = $count;
        $config['per_page'] = $nitem;
        $config['use_page_numbers'] = TRUE;
        $config['num_links'] = 10;
        //$config['num_tag_open'] = '<span class="page">';
        //$config['num_tag_close'] = '</span>';
        $config['first_link'] = 'Pertama';
        $config['last_link'] = 'Terakhir';
        $config['next_link'] = 'Berikutnya';
        $config['prev_link'] = 'Sebelumnya';
        $this->pagination->initialize($config);

		$data = array(
            //'output'=> $this->get(),
            'output' => $data_output,
            'page_title' => 'Cari Perjalanan',
            'page_content' => 'cari_perjalanan1',
            'isLogin' => $isLogin, 'user' => $user, 'id' => $id);
        $this->load->view($this->_public_view, $data);
	}
}
